//- Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd. 
//- <https://www.chatopera.com>, Licensed under the Chunsong Public 
//- License, Version 1.0  (the "License"), https://docs.cskefu.com/licenses/v1.html
//- Unless required by applicable law or agreed to in writing, software
//- distributed under the License is distributed on an "AS IS" BASIS,
//- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//- See the License for the specific language governing permissions and
//- limitations under the License.
//- Copyright (C) 2018-Jun. 2023 Chatopera Inc, <https://www.chatopera.com>
//- Licensed under the Apache License, Version 2.0
//- http://www.apache.org/licenses/LICENSE-2.0
extends /apps/include/layout.pug
block content
    .layui-side.layui-bg-black
        .layui-side-scroll
            include /apps/setting/include/left.pug
    .layui-body
        .layui-side-scroll
            .row
                .col-lg-12
                    h1.site-h1(style='background-color:#FFFFFF;')
                        | #{tagType.name} 标签 (#{tagList.totalElements})
                        span(style='float:right;')
                            button.layui-btn.layui-btn-small.green(href='/setting/tag/add.html?tagtype=' + tagType.code, data-toggle='ajax', data-width='650', data-height='270', data-title='添加标签') 添加标签
                    .row(style='padding:5px;')
                        .col-lg-12
                            table.layui-table(lay-skin='line')
                                colgroup
                                    col(width='20%')
                                    col(width='20%')
                                    col(width='20%')
                                    col(width='20%')
                                    col(width='1%')
                                    col
                                thead
                                    tr
                                        th 标签
                                        th 创建时间
                                        th 使用次数
                                        th 颜色
                                        th(style='white-space:nowrap;', nowrap) 操作
                                tbody
                                    if tagList.totalElements > 0
                                        for tag in tagList.content
                                            tr
                                                td: a(href="javascript:void(0)")= tag.tag
                                                td= pugHelper.formatDate('yyyy-MM-dd HH:mm:ss', tag.createtime)
                                                td= tag.times
                                                if tag.color
                                                    td: div.ukefu-im-theme: div.ukefu-tag(class='theme' + tag.color,style="color:#ffffff;" )= tag.tag
                                                else
                                                    td
                                                td(style="white-space:nowrap;" nowrap="nowrap")
                                                    a(href='/setting/tag/edit.html?id=' + tag.id + '&tagtype=' + tagType.code, data-toggle="ajax", data-width="650", data-height="270", data-title="编辑标签")
                                                        i(class="layui-icon") &#xe642;
                                                        span 编辑
                                                    a(href="/setting/tag/delete.html?id=" + tag.id + "&tagtype=" + tagType.code, style="margin-left:10px;", data-toggle="tip", data-title="请确认是否删除标签？")
                                                        i(class="layui-icon") &#x1006;
                                                        span 删除
                                    else
                                        td(colspan="20", style="height:400px;")
                                            div(class="ukefu-empty", style="background: none")
                                                i(class="layui-icon") &#xe63a;
                                                div(style="") 还没有标签记录
                    .row(style='padding:5px;')
                        .col-lg-12#page(style='text-align:center;')
script.
    layui.use(['laypage', 'layer'], function () {
        var laypage = layui.laypage
            , layer = layui.layer;

        laypage({
            cont: 'page'
            , pages: #{tagList.totalPages} //总页数
            , curr: #{tagList.number + 1}
            , groups: 5 //连续显示分页数
            , jump: function (data, first) {
                if (!first) {
                    location.href = "/setting/tag.html?p=" + data.curr;
                }
            }
        })
        ;
    });

